package com.miracle.common.util;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import java.util.ArrayList;

/**
 * com.miracle.common.util
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/7/5 13:41
 * @see com.miracle.common.util
 */
public class Utils {

    /**
     * 检查是否有空的字符串，如果为空 return true
     * @param view
     * @param strings
     * @param errors
     * @return
     */
    public static boolean checkNullList(View view, String[] strings, String[] errors) {
        for (int i = 0; i < strings.length; i++) {
            if (TextUtils.isEmpty(strings[i])) {
                S.Short(view, errors[i] + "不能为空").warning().show();
                return true;
            }
        }
        return false;
    }

    /**
     * 检查是否有空的字符串，如果为空 return true
     * @param view
     * @param strings
     * @param errors
     * @return
     */
    public static boolean checkNullList(View view, ArrayList<String> strings, ArrayList<String>
            errors) {
        for (int i = 0; i < strings.size(); i++) {
            if (TextUtils.isEmpty(strings.get(i))) {
                S.Short(view, errors.get(i) + "不能为空").warning().show();
                return true;
            }
        }
        return false;
    }

    /**
     * 防止空指针
     * @param strs
     * @return
     */
    public static String getSafetyString(String strs) {
        if (TextUtils.isEmpty(strs)) {
            return "";
        } else {
            return strs;
        }
    }
}
